#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QString>
#include <QMouseEvent>
#include "bspline.h"
#include "qcustomplot.h"

namespace Ui {
class MainWidget;
}

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MainWidget(QWidget *parent = 0);
    ~MainWidget();

private slots:
    void on_open_clicked();
    void on_save_clicked();
    void m_press(QMouseEvent* e);
    void m_move(QMouseEvent* e);
    void m_release(QMouseEvent* e);

    void on_add_clicked();

    void on_div_clicked();

    void on_mov_clicked();

    void on_del_clicked();

private:
    Ui::MainWidget *ui;
    bool pressed;
    int moveIndex;
    int insertIndex;
    int optFlag;//0 move 1 del
    QString basePath;
    QString filePath;
    QStringList listParams;
    QCPGraph* curGraph;
    QCPCurve* pathPos;
    QVector<QPointF> listPoint;

    QVector<QPointF> readCoors(QString fileName);
    void paintPoints(QVector<QPointF>);
    void setData(QVector<QPointF>);
    void setCurve(QVector<QPointF>);
    int findPoint(QPointF p, QVector<QPointF>, int range);
    QPoint mapToPix(QPointF p);
    QPointF pixToMap(QPointF p);
    QVector<QPointF> listDiv(QVector<QPointF> l, int step);
    QVector<QPointF> listInsert(QVector<QPointF> l, int step);
};

#endif // MAINWIDGET_H
